<?php
//获取文件的内容
$str = file_get_contents('18.html');
$preg='/<h1>(.*?)<\/h1>/is';
$replace="<h1><span style='color:red'>\\1</span></h1>";
echo preg_replace($preg, $replace, $str);

